<?
/**
 * ---------------------------------------------------------------------------------------------------------
 * Đây là các funtion liên quan đến phim dùng chung trong nhiều trang 
 * ---------------------------------------------------------------------------------------------------------
*/
/**
 * ---------------------------------------------------------------------------------------------------------
 * Trả về mảng 5 sản phẩm được active
 * ---------------------------------------------------------------------------------------------------------
*/
function support_online(){
   $arr = db_first("SELECT * 
                         FROM support_online
                         WHERE spo_active = 1
                         ORDER BY spo_id DESC
                         LIMIT 1
                        ");
   return $arr;
}
/**
 * ---------------------------------------------------------------------------------------------------------
 * Trả về mảng 5 sản phẩm được active
 * ---------------------------------------------------------------------------------------------------------
*/
function news_cat(){
   $news_cat = db_array("SELECT * 
                         FROM categories_multi
                         WHERE cat_type = 'news'
                         AND cat_parent_id != 0
                        ");
   return $news_cat;
}
/**
 * ---------------------------------------------------------------------------------------------------------
 * lấy danh mục con theo danh mục cha
 * ---------------------------------------------------------------------------------------------------------
*/
function product_cat($parent_id){
   $pro_cat = db_array("SELECT * 
                         FROM categories_multi
                         WHERE cat_type = 'services' AND cat_active = 1 AND cat_parent_id =" . $parent_id." ORDER BY cat_order ASC");
   return $pro_cat;
}
/**
 * ---------------------------------------------------------------------------------------------------------
 * lấy danh mục cha theo danh mục con
 * ---------------------------------------------------------------------------------------------------------
*/
function product_cat_parent($child_id){
   $cat_parent_id = db_one("SELECT cat_parent_id 
                         FROM categories_multi
                         WHERE cat_type = 'services' AND cat_active = 1 AND cat_id =" . $child_id);
   $product_cat_parent = db_first("SELECT * 
                                    FROM categories_multi
                                    WHERE cat_id = ".$cat_parent_id);
   return $product_cat_parent;
}
/**
 * ---------------------------------------------------------------------------------------------------------
 * Trả về mảng 6 bản ghi được active
 * ---------------------------------------------------------------------------------------------------------
*/
function People_talk(){
   $peo = db_array("SELECT * 
                     FROM people_talk
                     WHERE peo_active = 1
                     ORDER BY peo_order
                     LIMIT 6");
   return $peo;
}
/**
 * ---------------------------------------------------------------------------------------------------------
 * Trả về mảng 6 ảnh được active
 * ---------------------------------------------------------------------------------------------------------
*/
function pictures(){
   $pic = db_array("SELECT * 
                     FROM pictures
                     WHERE pic_active = 1
                     ORDER BY pic_position
                     LIMIT 6");
   return $pic;
}
function page_static($type) {
   $page = db_first("SELECT pag_id,pag_title,pag_summary 
                          FROM page_static
                          WHERE pag_active = 1 AND pag_type = '".$type."'
                          LIMIT 1");
   return $page;
}
function slides() {
   $slides = db_array('SELECT *
                  FROM slides
                  WHERE sli_active = 1 ORDER BY sli_position
                  ');
   return $slides;                
}
function services_new() {
   $services_new = db_array('SELECT *
                  FROM services
                  WHERE ser_active = 1 ORDER BY ser_date DESC LIMIT 10
                  ');
   return $services_new;                
}
function list_office(){
   $list_office = db_first('SELECT * FROM office_contact WHERE 1 ORDER BY off_id DESC LIMIT 1');
   return $list_office;
}
function link_footer(){
   $link_footer = db_array('SELECT * FROM link_footer WHERE lft_active = 1 ORDER BY lft_position ASC LIMIT 12');
   return $link_footer;
}
?>